function fun_dde_chen
%  ??Chen??
%
% ????:
%   dx/dt=a*(y-x)
%   dy/dt=(c-a)*x+c*y-x*z+k*(y(t-tau)-y)
%   dz/dt=x*y-b*z
%
% Author's email: ustb03-07@yahoo.com.cn
% ref: http://ustbchaos.blogspot.com/2007/03/chen-solution-with-delay.html

history = [-3;-4;14];
tspan = [0,25];
opts = ddeset('RelTol',1e-5,'AbsTol',1e-8);
a = 35;b = 3;c = 28;
 
k = 2.4;tau = .2;
% k = 2.8;tau = .15;
% k = 4.6;tau = .3;
% k = .8;tau = .5;
% k = 2.65;tau = .16;
% k = 4.2;tau = .1;
% k = 3.29;tau = .13;
% k = 2.3;tau = .18;
 
sol = dde23(@dde_chenf,tau,history,tspan,opts,a,b,c,k);
 
plot3(sol.y(1,4000:end),sol.y(2,4000:end),sol.y(3,4000:end))
title('Chen Solution with delay.')
xlabel('x(t)')
ylabel('y(t)')
zlabel('z(t)')
 
%--------------------------
 
function dydt = dde_chenf(t,y,Z,a,b,c,k)
% Differential equations function for Chen.
ylag = Z(:,1);
dydt = [ a*(y(2)-y(1))
         (c-a-y(3))*y(1)+c*y(2)+k*(ylag(2)-y(2))
         y(1)*y(2)-b*y(3)      ];
